Manual :: Installation of a local PEAR copy on a shared host 您所在的位置:网站首页 local copy Manual :: Installation of a local PEAR copy on a shared host

Manual :: Installation of a local PEAR copy on a shared host

2023-07-13 13:06| 来源: 网络整理| 查看: 265

Installing a local copy of PEAR through ftp/ftps/sftp

There are two ways to install a local copy of PEAR through ftp: the old, difficult way, and the new, easy way. The new, easy way requires an upgrade to version 1.4.3 or newer of PEAR.

New improved method using PEAR 1.4.3+ and PEAR_RemoteInstaller

Installing a local copy of PEAR through ftp has become a piece of cake in PEAR 1.4.3+.

One of the banes of many user's existence is trying to install PEAR on a remote host that does not have shell access. Often, the only choice is to use FTP, but even this is a problem for more complex packages that take advantage of installer features like replacements.

Here is the sequence necessary to get things running:

Make sure you are running PHP 5.0 or newer on your local computer

If you wish to use ftps, make sure you have enabled the openssl extension on your local computer in php.ini.

If you wish to use sftp, make sure you have enabled the ssh2 extension on your local computer in php.ini.

Make sure you have a working copy of the CLI version of PEAR on your local computer (the "pear" command, not the web interface)

Make sure you have ftp access to the remote host, and write access through ftp. (sftp or ftps is highly recommended for security reasons).

Note the full path to your home directory

Create a customized configuration file for both the local and remote host

Upload the remote configuration file to the remote host

Using the local configuration file, set the remote_config value to the location of the configuration file on the remote host

Manage packages at will using the remote-install, remote-uninstall, remote-upgrade and remote-upgrade-all commands.

1. Make sure you have a working copy of the CLI version of PEAR (the "pear" command, not the web interface)

Read The installation instructions.

2. Install package PEAR_RemoteInstaller locally if not already done.

3. Make sure you have ftp access to the remote host, and write access through ftp

This is pretty straightforward - if you can login using the ftp command in a DOS prompt or from a unix shell, you have ftp access.

Write down the user and password that you need to login.

Testing write access is easy. If you can upload a file, you have write access.

4. Note the full path to your home directory

This is also pretty straightforward. Upload this script to the root directory of your web host to find out:

Chances are, it will be something like: /home/username/htdocs or /home/username/public_html. When you log into ftp, if you can change directory to /home/username, that's great.

5. create a customized config file for both the local and the remote host

This is also quite simple. Here is how to do this on windows and unix.

Windows first:

Pick a location to store your local copy of the remote code. For example, C:\remote\pear. From a Command prompt (click Start here => Programs and search for the Command Prompt), type:

C:\> mkdir remoteC:\> cd remoteC:\remote\> mkdir pearC:\remote\> cd pearC:\remote\pear> pear config-create -w C:\remote\pear remote.iniC:\remote\pear> pear config-create /home/username/pear .pearrc       

In Unix, follow a similar process:

$ cd$ mkdir remote$ cd remote$ mkdir pear$ cd pear$ pear config-create /home/mylocaluser remote.conf$ pear config-create /home/username/pear .pearrc       

6. upload the remote configuration file to the remote host

This is straightforward - in both operating systems, use ftp to upload .pearrc to /home/username/pear/.pearrc

7. using the local configuration file, set the remote_config value to the location of the configuration file on the remote host

If you wish to use unencrypted ftp (remember: this is inherently insecure), then use ftp:// as your stream. If you wish to use ftps, then use ftps:// as your stream. If you wish to use sftp, then use ssh2.sftp as your stream.

The path you use for the remote_config variable may need to be a full pathname, as in:

ssh2.sftp://user:[email protected]/home/username/.pearrc       

If the initial connection attempt fails, try a relative path as in:

ftps://user:[email protected]/.pearrc       

To set the value of the remote_config configuration variable, use this syntax:

In windows:

C:\remote\pear\> pear -c remote.ini config-set remote_config \    ftp://user:[email protected]/.pearrc       

In Unix:

$ pear -c remote.conf config-set remote_config \    ftp://user:[email protected]/.pearrc       

8. Manage packages at will using the remote-install, remote-uninstall, remote-upgrade and remote-upgrade-all commands.

From this point on, you can synchronize the local and the remote repositories.

How does it work?

The installer installs the package locally, and then uses ftp streams and uploads a copy of each locally installed file to its equivalent location remotely. All commands that affect installation (install, uninstall, upgrade, and upgrade-all) have corresponding remote- commands (remote-install, remote-uninstall, remote-upgrade, remote-upgrade-all). The "remote_config" option tells the installer how to retrieve the remote configuration file containing absolute paths where packages should be installed.

The remote configuration file is used for any special tasks such as replacements. In other words, if a file expects to get the path to data files through the data_dir configuration directive, then it will have the path on the remote host (/home/username/pear/data) rather than the local copy ( C:\remote\pear\data). Note that packages installed this way will not work on the local machine, and should be thought of as a backup copy. In an emergency, you can always just upload the entire contents to the remote host using ftp or scp.

It is important to note that some packages install themselves differently on windows and on unix. Be sure you know whether this is the case before installing, or ensure that your local and remote systems are the same kind of operating system. In addition, your local packages may depend on PHP extensions. To ensure these are available on the remote server, use the output of phpinfo(); to determine which extensions are available.

The traditional way of installing a local copy of PEAR through ftp

In order to install a local copy of PEAR through ftp, you must have an ftp client that can set permissions on upload. First, create a directory that is NOT in your publicly accessible web space, and name it anything you'd like. Set it to be readable and writable by any user (permissions 0777). Then, download a copy of http://pear.php.net/go-pear.phar and save it as go-pear.php. Upload go-pear.php to a subdirectory of your publicly accessible web space. It is a very good idea to password-protect the directory containing go-pear.php with an .htaccess file.

Next, browse to the go-pear.php file. If your web address is http://www.example.com/, you have placed go-pear.php in public_html/install/go-pear.php, and http://www.example.com/ will browse to public_html/, then browse to http://www.example.com/install/go-pear.php. Follow the installation prompts. When asked where to install PEAR, choose the directory you created to be readable and writable by any user. You will need to know the location of the cli version of PHP. To find this, browse to this script and copy the output:

After PEAR has been installed, you can use the web installer to install and upgrade packages just as you would with any other PEAR installation. To use the files, you must set the include path in scripts on the website.



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有